package edu.nwpu.service.impl;

import edu.nwpu.dao.FoodCountMapper;
import edu.nwpu.pojo.FoodCount;
import edu.nwpu.service.FoodCountService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

@Service("foodCountService")
public class FoodCountServiceImpl implements FoodCountService {

    @Resource(name = "foodCountMapper")
    private FoodCountMapper foodCountMapper;

    @Override
    public FoodCount getFoodCountById(long orderId, Long foodId) {
        return foodCountMapper.selectFoodCountByPrimaryKey(orderId, foodId);
    }

    @Override
    public List<FoodCount> getFoodCountsByOrderId(long orderId) {
        return foodCountMapper.selectFoodCountsByOrderId(orderId);
    }

    @Override
    public int updateFoodCount(FoodCount foodCount) {
        return foodCountMapper.updateFoodCount(foodCount);
    }

    @Override
    public int deleteFoodCountById(long orderId, long foodId) {
        return foodCountMapper.deleteFoodCountById(orderId, foodId);
    }

    @Override
    public int deleteFoodCountsByOrderId(Long orderId) {
        return foodCountMapper.deleteFoodCountsByOrderId(orderId);
    }
}
